package com.lfg.leetcode.leetcode500;


public class No780reachingPoints {
    public static void main(String[] args) {
        System.out.println(reachingPoints(1, 1, 2, 1));
    }

    public static boolean reachingPoints(int sx, int sy, int tx, int ty) {
        while (tx > sx && ty > sy && tx != ty) {
            if (tx > ty) {
                tx %= ty;
            } else {
                ty %= tx;
            }
        }

        if (ty == sy && tx == sx) {
            return true;
        } else if (ty == sy) {
            return tx > sx && (tx - sx) % ty == 0;
        } else if (tx == sx) {
            return ty > sy && (ty - sy) % tx == 0;
        } else {
            return false;
        }

    }
}



